package com.jia.jianzhiOffer;

import java.util.Arrays;

/**
 * 剑指 Offer 61. 扑克牌中的顺子
 */
public class Pro61 {
    /**
     * 大小王可以变成癞子
     **/
    public boolean isStraight(int[] nums) {
        Arrays.sort(nums);
        int zeroCnt= 0, diff = 0;
        for(int i = 0; i < nums.length - 1; i++) {
            if(nums[i] == 0) {
                ++zeroCnt;
            }else {
                if(nums[i] == nums[i + 1]) return false;
                if(nums[i] + 1 != nums[i+1]) {
                    diff += nums[i+1] - nums[i] - 1;
                }
            }
        }
        return zeroCnt >= diff;
    }
}
